#ifndef MUTEX_H_
#define MUTEX_H_

#include <pthread.h>

class Mutex {
  public:
    // Initialise mutex.
    explicit Mutex();
    // Destroy mutex.
    ~Mutex();
    // Disable: copy constructor, assignment operator.

    // Lock the mutex. Blocks until mutex is unlocked.
    void lock();
    // Attempt to lock the mutex. Returns false if mutex already locked.
    bool trylock();
    // Unlock the mutex.
    void unlock();

  private:
    pthread_mutex_t mutex_;

    Mutex(const Mutex&);
    Mutex& operator=(const Mutex&);
};

#endif
